import { GCellRenderer } from "../../../../../com/mui/controls/GCellRenderer";
import { ObjCreate } from "../../common/ObjCreate";
import { ImagesConst } from "../../../resource/ImagesConst";
import { GTextFormat } from "../../../../common/GTextFormat";
import { SCrossStairRank } from "../../../../../Message/Public/SCrossStairRank";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { EntityUtil } from "../../../scene/layer/utils/EntityUtil";
import { Cache } from "../../../cache/Cache";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { PlayerUtil } from "../../common/util/PlayerUtil";
import { GTextFiled } from "../../../../../com/mui/controls/GTextFiled";
//class CrossStairRankRenderer
    
    export  class CrossStairRankRenderer extends GCellRenderer
    {
        constructor()
        {
            super();
            this.initUI();
            return;
        }

        protected initUI(): void
        {
            ObjCreate.createBg(0, 0, 372, 2, this, ImagesConst.SplitLine);
            this._rank = ObjCreate.createGTextField("", 0, 5, 50, 20, this, new GTextFormat(null, 12, 16715520, null, null, null, null, null, flash.text.TextFormatAlign.CENTER));
            this._name = ObjCreate.createGTextField("", 50, 5, 160, 20, this, new GTextFormat(null, 12, 16715520, null, null, null, null, null, flash.text.TextFormatAlign.CENTER));
            this._topLayer = ObjCreate.createGTextField("", 210, 5, 65, 20, this, new GTextFormat(null, 12, 16715520, null, null, null, null, null, flash.text.TextFormatAlign.CENTER));
            this._totalRevival = ObjCreate.createGTextField("", 275, 5, 85, 20, this, new GTextFormat(null, 12, 16715520, null, null, null, null, null, flash.text.TextFormatAlign.CENTER));
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            var loc1=null;
            var loc2=null;
            super.data = arg1;
            if (typeof data === "scrossstairrank") 
            {
                loc1 = data as SCrossStairRank;
                loc2 = GlobalStyle.color1;
                if (EntityUtil.equal(loc1.entityId, Cache.instance.role.entityInfo.entityId)) 
                {
                    loc2 = "#FFFF00";
                }
                this._rank.htmlText = HTMLUtil.addColor(loc1.rank + "", loc2);
                this._name.htmlText = HTMLUtil.addColor("[" + PlayerUtil.getProxyMsg(loc1.entityId) + "] " + loc1.name, loc2);
                this._topLayer.htmlText = HTMLUtil.addColor(loc1.floor + "", loc2);
                this._totalRevival.htmlText = HTMLUtil.addColor(loc1.totalRevivalNum + "", loc2);
            }
            return;
        }

        /* internal */ /* var */_rank: GTextFiled;

        /* internal */ /* var */_name: GTextFiled;

        /* internal */ /* var */_topLayer: GTextFiled;

        /* internal */ /* var */_totalRevival: GTextFiled;
    }
